from decimal import Decimal


def add(a, b):
    return a + b


def sub(a, b):
    return a - b


def mul(a, b):
    return a * b


def div(a, b):
    try:
        return a / b
    except ZeroDivisionError:
        return '除数不能为0'


while True:
    try:
        num1 = Decimal(input('请输入第一位数：'))
        num2 = Decimal(input('请输入第二位数：'))
    except ValueError as err:
        print('输入的不是两位有效数字，请重新输入！')
    else:
        while True:
                choice = input("请输入运算符（+ - * /）输入0时退出程序，输入1时重新输入：")
                if choice == "+":
                    print(add(num1, num2))
                elif choice == "-":
                    print(sub(num1, num2))
                elif choice == "*":
                    print(mul(num1, num2))
                elif choice == "/":
                    if type(div(num1, num2)) == Decimal:
                        print(f'{div(num1, num2):.2f}')
                    else:
                        print(div(num1, num2))
                elif choice == "0":
                    print('退出程序！')
                    exit(0)
                elif choice == "1":
                    print('请重新输入！')
                    break
                else:
                    print('输入错误，请重新输入：')
